package com.ruoyi.web.controller.emergency;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.emergency.domain.EpEscapeRoute;
import com.ruoyi.emergency.service.IEpEscapeRouteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 避灾路线管理Controller
 * 
 * @author hcc
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/control/route")
public class EpEscapeRouteController extends BaseController
{
    @Autowired
    private IEpEscapeRouteService epEscapeRouteService;

    /**
     * 查询避灾路线管理列表
     */
    @PreAuthorize("@ss.hasPermi('control:route:list')")
    @GetMapping("/list")
    public TableDataInfo list(EpEscapeRoute epEscapeRoute)
    {
        startPage();
        List<EpEscapeRoute> list = epEscapeRouteService.selectEpEscapeRouteList(epEscapeRoute);
        return getDataTable(list);
    }

    /**
     * 导出避灾路线管理列表
     */
    @PreAuthorize("@ss.hasPermi('control:route:export')")
    @Log(title = "避灾路线管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EpEscapeRoute epEscapeRoute)
    {
        List<EpEscapeRoute> list = epEscapeRouteService.selectEpEscapeRouteList(epEscapeRoute);
        ExcelUtil<EpEscapeRoute> util = new ExcelUtil<EpEscapeRoute>(EpEscapeRoute.class);
        util.exportExcel(response, list, "避灾路线管理数据");
    }

    /**
     * 获取避灾路线管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:route:query')")
    @GetMapping(value = "/{escapeRouteId}")
    public AjaxResult getInfo(@PathVariable("escapeRouteId") String escapeRouteId)
    {
        return success(epEscapeRouteService.selectEpEscapeRouteByEscapeRouteId(escapeRouteId));
    }

    /**
     * 新增避灾路线管理
     */
    @PreAuthorize("@ss.hasPermi('control:route:add')")
    @Log(title = "避灾路线管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpEscapeRoute epEscapeRoute)
    {
        return toAjax(epEscapeRouteService.insertEpEscapeRoute(epEscapeRoute));
    }

    /**
     * 修改避灾路线管理
     */
    @PreAuthorize("@ss.hasPermi('control:route:edit')")
    @Log(title = "避灾路线管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpEscapeRoute epEscapeRoute)
    {
        return toAjax(epEscapeRouteService.updateEpEscapeRoute(epEscapeRoute));
    }

    /**
     * 删除避灾路线管理
     */
    @PreAuthorize("@ss.hasPermi('control:route:remove')")
    @Log(title = "避灾路线管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{escapeRouteIds}")
    public AjaxResult remove(@PathVariable String[] escapeRouteIds)
    {
        return toAjax(epEscapeRouteService.deleteEpEscapeRouteByEscapeRouteIds(escapeRouteIds));
    }
}
